
<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>数据分析</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-tab layui-tab-brief">
      <ul class="layui-tab-title">
        <li class="layui-this">支付产品统计</li>
      </ul>
      <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
          <div class="layui-row" style="margin-bottom: 10px;">
            <blockquote class="layui-elem-quote" id="amountTip" style="float:left">
            充值总金额:<span id="totalAmounts" style="color: green; margin-left: 10px;"></span>
            <span style="color: red;font-size: 18px">充值金额=处理完成</span>
            </blockquote>
            <div class="layui-form" style="float:right;">
              <div class="layui-form-item" style="margin:0;">
                <div class="layui-input-inline">
                  <input type="text" name="createTimeStart" id="createTimeStart" autocomplete="off" placeholder="起始时间" class="layui-input">
                </div>
                <div class="layui-input-inline">
                  <input type="text" name="createTimeEnd" id="createTimeEnd" autocomplete="off" placeholder="结束时间" class="layui-input">
                </div>
                <button id="search" class="layui-btn" data-type="reload">搜索</button>
              </div>
            </div>
          </div>

          <table id="JeePay_Bcd_User_dataAll" lay-filter="JeePay_Bcd_User_dataAll"></table>
        </div>

      </div>
    </div>
  </div>
</div>

<script>
layui.use(['admin', 'table', 'util', 'laydate'], function(){
  var $ = layui.$
  ,admin = layui.admin
  ,table = layui.table
  ,element = layui.element
  ,laydate = layui.laydate
  ,form = layui.form;
  
  element.render('breadcrumb', 'breadcrumb');

  var tplOutAmount2 = function(d){
    return d.outAmount - d.feeAmount;
  };

  //用户统计列表
  table.render({
    elem: '#JeePay_Bcd_User_dataAll'
    ,cellMinWidth: 90
    ,url: layui.setter.baseUrl + '/data/count4PayProduct'
    ,where: {
      access_token: layui.data(layui.setter.tableName).access_token
    }
    ,initSort: {
      field: 'totalAmount' //排序字段，对应 cols 设定的各字段名
      ,type: 'desc' //排序方式  asc: 升序、desc: 降序、null: 默认排序
    }
    ,id: 'tableReload'
    ,page: false
    ,cols: [[
      {field: 'productId', title: '产品ID'}
      ,{field: 'productName', title: '产品名称'}
      ,{field: 'totalAmount', title: '充值金额', sort: true, templet: '<div>{{ d.totalAmount/100 }}</div>'}
      ,{field: 'totalCount', title: '充值笔数', sort: true}
    ]]
    ,skin: 'line'
  });

        $.collInit = function () {
            var createTimeStart = $('#createTimeStart').val();
            var createTimeEnd = $('#createTimeEnd').val();
            admin.req({
                type: 'post',
                url: layui.setter.baseUrl + '/data/count4PayProductAll',
                data: {
                    createTimeStart: createTimeStart,
                    createTimeEnd: createTimeEnd
                },
                error: function (err) {
                    layer.alert(err);
                },
                success: function (res) {
                    if (res.code == 0) {
                        debugger;
                        var spName = document.getElementById("totalAmounts");
                        spName.innerText = res.data.totalAmount/100;
                    }
                }
            });
        };

        $.collInit(); //初始化

        // 搜索
        var $ = layui.$, active = {
            reload: function () {
                var createTimeStart = $('#createTimeStart').val();
                var createTimeEnd = $('#createTimeEnd').val();
                //执行重载
                table.reload('tableReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , page: false
                    , where: {
                        createTimeStart: createTimeStart,
                        createTimeEnd: createTimeEnd
                    }
                });
                admin.req({
                    type: 'post',
                    url: layui.setter.baseUrl + '/data/count4PayProductAll',
                    data: {
                        createTimeStart: createTimeStart,
                        createTimeEnd: createTimeEnd
                    },
                    error: function (err) {
                        layer.alert(err);
                    },
                    success: function (res) {
                        if (res.code == 0) {
                            debugger;
                            var spName = document.getElementById("totalAmounts");
                            spName.innerText = res.data.totalAmount/100;
                        }
                    }
                });

            }
        };

  // 渲染表单
  form.render();
});
</script>